package com.ruoyi.jxxwx.controller;

import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jxxwx.domain.JxxPatrol;
import com.ruoyi.jxxwx.service.IJxxPatrolService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

import java.util.List;

/**
 * 巡查记录Controller
 * 
 * @author wh
 * @date 2025-04-10
 */
@RestController
@RequestMapping("/jxxwx/patrol")
public class JxxPatrolController extends BaseController
{
    @Autowired
    private IJxxPatrolService jxxPatrolService;

    /**
     * 查询巡查记录列表
     */
    @PreAuthorize("@ss.hasPermi('jxxwx:patrol:list')")
    @GetMapping("/list")
    public TableDataInfo list(JxxPatrol jxxPatrol)
    {
        startPage();
        List<JxxPatrol> list = jxxPatrolService.selectJxxPatrolList(jxxPatrol);
        return getDataTable(list);
    }

    /**
     * 导出巡查记录列表
     */
    @PreAuthorize("@ss.hasPermi('jxxwx:patrol:export')")
    @Log(title = "巡查记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JxxPatrol jxxPatrol)
    {
        List<JxxPatrol> list = jxxPatrolService.selectJxxPatrolList(jxxPatrol);
        ExcelUtil<JxxPatrol> util = new ExcelUtil<JxxPatrol>(JxxPatrol.class);
        util.exportExcel(response, list, "巡查记录数据");
    }

    /**
     * 获取巡查记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('jxxwx:patrol:query')")
    @GetMapping(value = "/{patrolId}")
    public AjaxResult getInfo(@PathVariable("patrolId") Long patrolId)
    {
        return AjaxResult.success(jxxPatrolService.selectJxxPatrolByPatrolId(patrolId));
    }

    /**
     * 新增巡查记录
     */
    @PreAuthorize("@ss.hasPermi('jxxwx:patrol:add')")
    @Log(title = "巡查记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JxxPatrol jxxPatrol)
    {
        return toAjax(jxxPatrolService.insertJxxPatrol(jxxPatrol));
    }

    /**
     * 修改巡查记录
     */
    @PreAuthorize("@ss.hasPermi('jxxwx:patrol:edit')")
    @Log(title = "巡查记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JxxPatrol jxxPatrol)
    {
        return toAjax(jxxPatrolService.updateJxxPatrol(jxxPatrol));
    }

    /**
     * 删除巡查记录
     */
    @PreAuthorize("@ss.hasPermi('jxxwx:patrol:remove')")
    @Log(title = "巡查记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{patrolIds}")
    public AjaxResult remove(@PathVariable Long[] patrolIds)
    {
        return toAjax(jxxPatrolService.deleteJxxPatrolByPatrolIds(patrolIds));
    }
}
